<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>旅游村接口-思途CMS{$coreVersion}</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,plist.css,sms_sms.css,base_new.css'); }
    {php echo Common::getScript('common.js,config.js,DatePicker/WdatePicker.js');}
</head>
<body>
<table class="content-tab" html_size=Pan0Zk >
    <tr>
        <td width="119px" class="content-lt-td" valign="top">
            {template 'stourtravel/public/leftnav'}
            <!--右侧内容区-->
        </td>
        <td valign="top" class="content-rt-td">
            <!--面包屑-->
            <div class="cfg-header-bar">
                <!--<a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" id="resetapps">重置</a>-->
                <a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>
            </div>
            <form id="configfrm">
                <ul class="info-item-block">
<!--                    <li>
                        <span class="item-hd">APP ID{Common::get_help_icon('cfg_zhilvyun_app_id')}：</span>
                        <div class="item-bd">
                            <span class="item-text c-999">
                                <input type="text" name="app_id" class="input-text w300"
                                       value="{$newdata['app_id']}">
                            </span>
                        </div>
                    </li>
                    <li>
                        <span class="item-hd">APP Secret{Common::get_help_icon('cfg_zhilvyun_app_secret')}：</span>
                        <div class="item-bd">
                            <span class="item-text c-999">
                                <input type="text" name="app_secret" class="input-text w300"
                                       value="{$newdata['app_secret']}">
                            </span>
                        </div>
                    </li>-->
                    <li>
                        <span class="item-hd">partnerId{Common::get_help_icon('cfg_zhilvyun_partnerId')}：</span>
                        <div class="item-bd">
                            <span class="item-text c-999">
                                <input type="text" name="partnerId" class="input-text w300"
                                       value="{$newdata['partnerId']}">
                            </span>
                        </div>
                    </li>
                    <li>
                        <span class="item-hd">回调URL{Common::get_help_icon('cfg_zhilvyun_app_notify_url')}：</span>
                        <div class="item-bd">
                            <input type="text" name="consume_callback_url" class="input-text w300"
                                   value="{$newdata['consume_callback_url']}">
                        </div>
                    </li>
                    <input type="hidden" name="webid" value="0"/>
                    <input type="hidden" name="id" value="{$newdata['id']}"/>
                </ul>
            </form>
            <div class="clear clearfix mt-20">
                <a href="javascript:;" id="btn_save" class="btn btn-primary radius size-L ml-115">保存</a>
            </div>
        </td>
    </tr>
</table>
<script>
    $(function () {
        $("#btn_save").click(function () {
            $.ajax({
                type: 'POST',
                url: SITEURL + "distribute/zhilvyun/admin/config/index",
                dataType: 'json',
                data: $("#configfrm").serialize(),
                success: function (data) {
                    if (data.status == true) {
                        ST.Util.showMsg('保存成功', 4);
                    } else {
                        ST.Util.showMsg('绑定失败', 5);
                    }
                }
            })
        });
        $("#resetapps").click(function () {
            ST.Util.confirmBox("提示", "确定重置？", function () {
                $.ajax({
                    type: 'POST',
                    url: SITEURL + "distribute/zhilvyun/admin/ctrip/reset",
                    dataType: 'json',
                    success: function (data) {
                        if (data.status == true) {
                            ST.Util.showMsg('重置成功', 4, 1000);
                            setTimeout(function () {
                                window.location.reload();
                            }, 1000)
                        } else {
                            ST.Util.showMsg('重置失败', 5);
                        }
                    }
                })
            })

    });

    //获取数据
    (function (webid) {
        var fields = ['cfg_lyc_app_id', 'cfg_lyc_app_secret'];
        Config.getConfig(webid, function (data) {
            for (var i = 0; i < fields.length; i++) {
                $('input[name="' + fields[i] + '"]').val(data[fields[i]])
            }
        }, fields);

    })(0);
    })
</script>
</body>
</html>
